/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSTransformationElement.h
 *
 *  Created on: 2010/03/04
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSTRANSFORMATIONELEMENT_H_
#define RSTRANSFORMATIONELEMENT_H_

#include "RSElement.h"
#include <QMatrix4x4>

namespace Realsphere {

    class RSTransformationElement: public Realsphere::RSElement {
        Q_OBJECT
        Q_PROPERTY ( QString _attr_sid READ ScopeId WRITE SetScopeId )
        public:
            RSTransformationElement ( RSTransformationType rTransformationType,
                                      const QString& rScopeId = QString::null );
            virtual ~RSTransformationElement() = 0;

        public:
            QString                 ScopeId () const;
            bool                    IsDirty () const;
            bool                    IsRootElement () const;
            QMatrix4x4              Transformation();
            RSTransformationType    TransformationType () const;

        public slots:
            void                    SetScopeId ( const QString& rScopeId, bool rEmit = true );
            void                    SetDirty ( bool rOnOff );

        signals:
            void                    ScopeIdChanged ( const QString& rScopeId );

        protected:
            RSError                 BeforeAddChildElement ( RSElement* rChild );
            virtual void            UpdateTransformation () = 0;
            void                    SetTransformation ( const QMatrix4x4& rTransformation );

        public:
            static QString TransformationTypeToTag ( RSTransformationType rTransformationType );
            static RSTransformationType TransformationTagtoType ( const QString &rTag );

        private:
            RSTransformationType    mTransformationType;
            QString                 mScopeId;
            QMatrix4x4              mTransformation;
            bool                    mDirty;
    };

}

#endif /* RSTRANSFORMATIONELEMENT_H_ */
